//
//  LZMusicSingleton.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "LZMusicSingleton.h"
#import "ZBBPlayHistory.h"
#import "TabBarController.h"
#import "UIImageView+WebCache.h"
@implementation LZMusicSingleton

+ (LZMusicSingleton *)shareInstance{
    static LZMusicSingleton *lzMusic = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        lzMusic = [[LZMusicSingleton alloc]init];
    });
    return lzMusic;
}
-(void)ZbbPlay:(NSDictionary *)dic
{
    [_player pause];
    _player = nil;
    NSString *mp3String =  [dic objectForKey:@"listenBackUrl"] ;
    _player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:mp3String]];
    [_player play];


    
    
   }


- (void)play:(NSDictionary *)dic
{
    [_player pause];
    NSString *mp3String = @"playPath64";
    [[TabBarController shareInstance].imageView sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"coverLarge"]]];
    
    if ([[dic objectForKey:mp3String] length] == 0) {
        mp3String = @"playPathAacv224";
        if ([[dic objectForKey:mp3String] length] == 0) {
            mp3String = @"play_path_64";
        }
    }
//    if ([[dic objectForKey:mp3String] length] == 0 && [[dic objectForKey:mp3String] length] != 0) {
//        mp3String = @"playPathAacv164";
//    }
//    else{
    
    _player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:[dic objectForKey:mp3String]]];
    [_player play];
    [[ZBBPlayHistory shareInstance] addDictionary:dic];
    [[ZBBPlayHistory shareInstance] WriteToFile:@"LZString"];
//    }
    
}

- (void)pause{
    [_player pause];
}

@end
